package com.toune.villager.adapter

import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.toune.villager.R
import com.toune.villager.bean.GoodsListBean

class GoodsListAdapter(data: MutableList<GoodsListBean.RowsBean>?) :
    BaseMultiItemQuickAdapter<GoodsListBean.RowsBean, BaseViewHolder>(data),LoadMoreModule {

    init {
        addItemType(GoodsListBean.RowsBean.LIST_STYLE, R.layout.adapter_list_goods)
        addItemType(GoodsListBean.RowsBean.GRID_STYLE, R.layout.adapter_grid_goods)
    }

    override fun convert(holder: BaseViewHolder, item: GoodsListBean.RowsBean) {
        when (GoodsListBean.RowsBean.style) {
            GoodsListBean.RowsBean.GRID_STYLE -> {
                holder.setText(R.id.goodsNameTv, item.goodName)
                holder.setText(R.id.goodsPriceTv, "￥${item.price}")
                holder.setText(R.id.desTv, item.des)
//                Glide.with(context).load(item)
            }
            GoodsListBean.RowsBean.LIST_STYLE -> {
                holder.setText(R.id.goodsNameTv, item.goodName)
                holder.setText(R.id.goodsPriceTv, "￥${item.price}")
                holder.setText(R.id.desTv, item.des)
            }
        }
    }

}